<?php 

Class appController extends Controller
{
	
    public function _initialize()
	{ 
		
		if (isset($_GET['code'])&&hy_check($_GET['code'],'un')=='#@_error')
		{
			hy_404();
		}
		
       $this->registerPlugin("function","func",array('appController','tpl_model'));
    
	}
	
	// 注册一下
	
	public static function tpl_model($arg)
	{
		if(!empty($arg['model'])&&!empty($arg['action']))
			$item=Model($arg['model'])->$arg['action']($arg);
	
		return $item;
	}
	public function assign_global($config=array())
	{
		$cfg=Model('app')->get_cfg();
		
		if(isset($config['c']))
		{
			foreach($config['c'] as $k=>$v)
			{
				if(isset($cfg[$k]))
				{
					$cfg[$k]=$v;
					
				}
			}
		}
		C($cfg);
		
		C('lang',DEFAULT_LANG);
		//样式路径
		
		
		
		$path=SUBDIR."/Mobile/Webroot/".C('home_tpl').'/';	
		$this->set_tpl_dir('',C('home_tpl'));
		C('hy_path',$path);
		
		
	
		//配置
		
		$this -> assign('_GET',$_GET);
		$this -> assign('_C',C());
		$this -> assign('_L',Lang());
	}
	
}


